Skip to content

Conversation

LorrensP-2158466
Copy link
Contributor

@LorrensP-2158466 LorrensP-2158466 commented Aug 12, 2025

This pr tries to resolve the prelude import at the build_reduced_graph stage.
Part of batched import resolution in #145108 (cherry picked commit) and maybe needed for #139493.

r? petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 12, 2025
@petrochenkov
Copy link
Contributor

Could you also add this case to tests?

//@ check-pass

#![feature(custom_inner_attributes)]

#![rustfmt::skip]

fn main() {
    let _ = todo!();
}

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2025
@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Aug 12, 2025

I am currently unable to implement any of your suggestions; it is the prelude import that can not be resolved during build_reduced_graph. Which makes me think that this change doesn't actually do anything useful? At least the prelude import in stdlib keeps failing with every change.

@petrochenkov
Copy link
Contributor

@Voultapher
This change should fix your issues with #139493 and custom inner attributes.
Could you check it when it's ready?

@LorrensP-2158466
Copy link
Contributor Author

Suggestions worked, however, we can't emit an error when the prelude is already set, I just used a panic for ease of use, and it was triggered when compiling stdlib:

prelude already set: [Segment { ident: prelude#0, id: Some(NodeId(479)), has_generic_args: false, has_lifetime_args: false, args_span: no-location (#0) }, Segment { ident: rust_2021#0, id: Some(NodeId(480)), has_generic_args: false, has_lifetime_args: false, args_span: no-location (#0) }]

I also can't avoid to only resolve the prelude path when the prelude is not set. Errors like these get emitted:

error[E0433]: failed to resolve: use of undeclared type `String`
   --> library/std/src/panicking.rs:642:29
    |
642 |                 let mut s = String::new();
    |                             ^^^^^^ use of undeclared type `String`
    |
help: consider importing one of these structs
    |
 12 + use crate::prelude::rust_future::String;
    |
 12 + use alloc::string::String;
    |

error[E0433]: failed to resolve: use of undeclared type `Box`
   --> library/std/src/panicking.rs:656:13
    |
656 |             Box::into_raw(Box::new(contents))
    |             ^^^ use of undeclared type `Box`
    |
help: consider importing one of these structs
    |
 12 + use crate::prelude::rust_future::Box;
    |
 12 + use alloc::boxed::Box;

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2025
@petrochenkov
Copy link
Contributor

Okay, I see, in std and in some tests we first apply the prelude import injected implicitly, and then the prelude import written explicitly.
Let's keep it as is then.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
@rust-log-analyzer

This comment has been minimized.

@Voultapher
Copy link
Contributor

@petrochenkov I've tested #139493 with this PR and I can confirm it does resolve the problem in question, but I'm also seeing the same UI test failures reported by the CI here.

@Voultapher
Copy link
Contributor

Small addendum, I had hopped that fixing the custom_inner_attributes issue would also resolve the change in errors produced in the where-allowed test since it uses custom_inner_attributes and a top level non prelude macro, but alas the change in errors produced still occurs.

@LorrensP-2158466
Copy link
Contributor Author

Which tests are you talking about?

@LorrensP-2158466
Copy link
Contributor Author

I also tried to make CI green, those changes are in the second commit.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 14, 2025
@LorrensP-2158466 LorrensP-2158466 force-pushed the early-prelude-processing branch from 1c9ebd8 to 0ae3040 Compare August 14, 2025 13:03
@petrochenkov
Copy link
Contributor

r=me after fixing typos #145322 (comment) and squashing commits.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 14, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@LorrensP-2158466 LorrensP-2158466 force-pushed the early-prelude-processing branch from 0ae3040 to ff560d3 Compare August 14, 2025 13:29
@LorrensP-2158466
Copy link
Contributor Author

@bors2 r=petrochenkov

@rustbot ready

@rust-bors
Copy link

rust-bors bot commented Aug 14, 2025

@LorrensP-2158466: 🔑 Insufficient privileges: not in review users

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 14, 2025
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 14, 2025

📌 Commit ff560d3 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
…cessing, r=petrochenkov

Resolve the prelude import in `build_reduced_graph`

This pr tries to resolve the prelude import at the `build_reduced_graph` stage.
Part of batched import resolution in rust-lang#145108 (cherry picked commit) and maybe needed for rust-lang#139493.

r? petrochenkov
bors added a commit that referenced this pull request Aug 15, 2025
Rollup of 22 pull requests

Successful merges:

 - #118087 (Add Ref/RefMut try_map method)
 - #122661 (Change the desugaring of `assert!` for better error output)
 - #140740 (Add `-Zindirect-branch-cs-prefix`)
 - #142640 (Implement autodiff using intrinsics)
 - #143075 (compiler: Allow `extern "interrupt" fn() -> !`)
 - #144865 (Fix tail calls to `#[track_caller]` functions)
 - #144944 (E0793: Clarify that it applies to unions as well)
 - #144947 (Fix description of unsigned `checked_exact_div`)
 - #145004 (Couple of minor cleanups)
 - #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
 - #145012 (Tail call diagnostics to include lifetime info)
 - #145065 (resolve: Introduce `RibKind::Block`)
 - #145120 (llvm: Accept new LLVM lifetime format)
 - #145189 (Weekly `cargo update`)
 - #145235 (Minor `[const]` tweaks)
 - #145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
 - #145322 (Resolve the prelude import in `build_reduced_graph`)
 - #145331 (Make std use the edition 2024 prelude)
 - #145369 (Do not ICE on private type in field of unresolved struct)
 - #145378 (Add `FnContext` in parser for diagnostic)
 - #145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
 - #145392 (coverage: Remove intermediate data structures from mapping creation)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
…cessing, r=petrochenkov

Resolve the prelude import in `build_reduced_graph`

This pr tries to resolve the prelude import at the `build_reduced_graph` stage.
Part of batched import resolution in rust-lang#145108 (cherry picked commit) and maybe needed for rust-lang#139493.

r? petrochenkov
bors added a commit that referenced this pull request Aug 15, 2025
Rollup of 21 pull requests

Successful merges:

 - #118087 (Add Ref/RefMut try_map method)
 - #122661 (Change the desugaring of `assert!` for better error output)
 - #142640 (Implement autodiff using intrinsics)
 - #143075 (compiler: Allow `extern "interrupt" fn() -> !`)
 - #144865 (Fix tail calls to `#[track_caller]` functions)
 - #144944 (E0793: Clarify that it applies to unions as well)
 - #144947 (Fix description of unsigned `checked_exact_div`)
 - #145004 (Couple of minor cleanups)
 - #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
 - #145012 (Tail call diagnostics to include lifetime info)
 - #145065 (resolve: Introduce `RibKind::Block`)
 - #145120 (llvm: Accept new LLVM lifetime format)
 - #145189 (Weekly `cargo update`)
 - #145235 (Minor `[const]` tweaks)
 - #145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
 - #145322 (Resolve the prelude import in `build_reduced_graph`)
 - #145331 (Make std use the edition 2024 prelude)
 - #145369 (Do not ICE on private type in field of unresolved struct)
 - #145378 (Add `FnContext` in parser for diagnostic)
 - #145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
 - #145392 (coverage: Remove intermediate data structures from mapping creation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 14e2886 into rust-lang:master Aug 15, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 15, 2025
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #145322 - LorrensP-2158466:early-prelude-processing, r=petrochenkov

Resolve the prelude import in `build_reduced_graph`

This pr tries to resolve the prelude import at the `build_reduced_graph` stage.
Part of batched import resolution in #145108 (cherry picked commit) and maybe needed for #139493.

r? petrochenkov
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 18, 2025
Rollup of 21 pull requests

Successful merges:

 - rust-lang/rust#118087 (Add Ref/RefMut try_map method)
 - rust-lang/rust#122661 (Change the desugaring of `assert!` for better error output)
 - rust-lang/rust#142640 (Implement autodiff using intrinsics)
 - rust-lang/rust#143075 (compiler: Allow `extern "interrupt" fn() -> !`)
 - rust-lang/rust#144865 (Fix tail calls to `#[track_caller]` functions)
 - rust-lang/rust#144944 (E0793: Clarify that it applies to unions as well)
 - rust-lang/rust#144947 (Fix description of unsigned `checked_exact_div`)
 - rust-lang/rust#145004 (Couple of minor cleanups)
 - rust-lang/rust#145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
 - rust-lang/rust#145012 (Tail call diagnostics to include lifetime info)
 - rust-lang/rust#145065 (resolve: Introduce `RibKind::Block`)
 - rust-lang/rust#145120 (llvm: Accept new LLVM lifetime format)
 - rust-lang/rust#145189 (Weekly `cargo update`)
 - rust-lang/rust#145235 (Minor `[const]` tweaks)
 - rust-lang/rust#145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
 - rust-lang/rust#145322 (Resolve the prelude import in `build_reduced_graph`)
 - rust-lang/rust#145331 (Make std use the edition 2024 prelude)
 - rust-lang/rust#145369 (Do not ICE on private type in field of unresolved struct)
 - rust-lang/rust#145378 (Add `FnContext` in parser for diagnostic)
 - rust-lang/rust#145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
 - rust-lang/rust#145392 (coverage: Remove intermediate data structures from mapping creation)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Aug 18, 2025
…cessing, r=petrochenkov

Resolve the prelude import in `build_reduced_graph`

This pr tries to resolve the prelude import at the `build_reduced_graph` stage.
Part of batched import resolution in rust-lang#145108 (cherry picked commit) and maybe needed for rust-lang#139493.

r? petrochenkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants